'use strict';
/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface, Sequelize) {
    await queryInterface.createTable('edu_user_scores', {
      id: {
        allowNull: false,
        autoIncrement: true,
        primaryKey: true,
        type: Sequelize.INTEGER.UNSIGNED,
      },
      user_id: {
        allowNull: false,
        type: Sequelize.INTEGER.UNSIGNED,
        comment: '用户ID',
      },
      type: {
        allowNull: false,
        type: Sequelize.INTEGER.UNSIGNED,
        defaultValue: 0,
        comment: '积分变动分类:0-学生邀请学生送积分,1-课程购买抵扣积分',
      },
      score: {
        allowNull: false,
        type: Sequelize.INTEGER,
        comment: '积分，可以存正负数',
      },
      balance: {
        allowNull: false,
        type: Sequelize.INTEGER.UNSIGNED,
        comment: '积分余额',
      },
      remark: {
        allowNull: false,
        type: Sequelize.STRING,
        defaultValue: '',
        comment: '备注',
      },
      deleted_at: {
        type: Sequelize.DATE,
      },
      created_at: {
        allowNull: false,
        type: Sequelize.DATE,
      },
      updated_at: {
        allowNull: false,
        type: Sequelize.DATE,
      },
    });
  },
  async down(queryInterface, Sequelize) {
    await queryInterface.dropTable('edu_user_scores');
  },
};
